import request from '@/utils/request'

const baseURL = '/api/selection'

export function getSelectionList({
                                   page, pageSize, params = {}, data
                                 }) {
  return request({
    url: baseURL + '/list',
    method: 'post',
    params: {
      page, pageSize,
      ...params
    }, data
  })
}

export function getElectiveSelectionList({
                                   page, pageSize, params = {}, data
                                 }) {
  return request({
    url: baseURL + '/electiveSelectionList',
    method: 'post',
    params: {
      page, pageSize,
      ...params
    }, data
  })
}

export function getOneSelection(id) {
  return request({
    url: baseURL + `/${id}`,
    method: 'get'
  })
}

export function addSelection(data) {
  return request({
    url: baseURL,
    method: 'post',
    data
  })
}

export function updateSelection(id, data) {
  return request({
    url: baseURL + `/${id}`,
    method: 'put',
    data
  })
}

export function deleteOneSelection(id) {
  return request({
    url: baseURL + `/${id}`,
    method: 'delete'
  })
}

export function selectCourse(courseId) {
  return request({
    url: baseURL + `/select/${courseId}`,
    method: 'get'
  })
}

export function cancelSelect(courseId) {
  return request({
    url: baseURL + `/cancel/${courseId}`,
    method: 'get'
  })
}

export function getAllSelection(courseId) {
  return request({
    url: baseURL + `/allSelection/${courseId}`,
    method: 'get',
  })
}

export function enterGrade(selectionId, score) {
  return request({
    url: baseURL + `/grade/${selectionId}/${score}`,
    method: 'put',
  })
}
